package com.harper.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 硬编码的方式
 */
@RestController
public class NacosConfigController {

    @Autowired
    private ConfigurableApplicationContext applicationContext;

    /**
     * 硬编码的方式获取nacos配置
     * @return
     */
    @GetMapping("/nacos-config-test1")
    public String nacosConfingTest1() {
        // 硬编码方式获取nacos配置
        return applicationContext.getEnvironment().getProperty("config.appName");
    }


}
